package com.team.employment.web.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.team.employment.model.entity.RecruitmentInfo;
import com.team.employment.model.entity.ResumeInfo;
import com.team.employment.model.entity.UserFavorite;
import com.team.employment.web.admin.dto.ResumeSearchDto;
import com.team.employment.web.admin.service.RecruitmentInfoService;

import com.team.employment.web.admin.mapper.RecruitmentInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
* @author jade
* @description 针对表【recruitment_info(招聘信息表)】的数据库操作Service实现
* @createDate 2025-04-11 15:49:27
*/
@Service
public class RecruitmentInfoServiceImpl extends ServiceImpl<RecruitmentInfoMapper, RecruitmentInfo>
    implements RecruitmentInfoService{
    @Autowired
    private RecruitmentInfoMapper recruitmentInfoMapper;

    @Override
    public IPage<ResumeInfo> pageQueryInfo(IPage<ResumeInfo> page, ResumeSearchDto resumeSearchDto) {
        IPage<ResumeInfo> list = recruitmentInfoMapper.pageQueryInfo(page,resumeSearchDto);
        return list;
    }

    @Override
    public IPage<RecruitmentInfo> pageUserFavorite(IPage<RecruitmentInfo> page, List<UserFavorite> list) {
        LambdaQueryWrapper<RecruitmentInfo> wrapper = new LambdaQueryWrapper<>();
        List<Long> recruitmentIds = list.stream().map(UserFavorite::getRecruitmentId).collect(Collectors.toList());
        wrapper.in(RecruitmentInfo::getId,recruitmentIds);
        IPage<RecruitmentInfo> recruitmentInfoIPage = recruitmentInfoMapper.selectPage(page, wrapper);
        return recruitmentInfoIPage;
    }

    @Override
    public RecruitmentInfo getRecruitmentInfoById(Long id) {
        return recruitmentInfoMapper.getRecruitmentInfoById(id);
    }

}




